import Vue from 'vue'
import request from '@/itsoftUI/utils/request'
import qs from "qs"
const baseUrl = Vue.prototype.$serviceUrl + "/repairInspection"

//数据字典api
export const areaApi = {
  schoolList: function () {
    const data = {
      order: 'createTime desc'
    }
    return request({
      url: baseUrl + '/schoolAreaInfo/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 保存巡检人员或管理人员
  batchSaveRegionUser: function (ids, type, regionUserList) {
    const data = {
      ids, type, regionUserList
    }
    return request({
      url: baseUrl + '/regionInfo/batchSaveRegionUser ',
      method: 'post',
      data: qs.stringify(data)
    })

  },
  // 删除人员
  deleteRegionUser: function (id, userId) {
    const data = {
      id, userId
    }
    return request({
      url: baseUrl + '/regionInfo/deleteRegionUser ',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 用户
  userList: function (search, order) {
    const data = {
      search, order
    }
    return request({
      url: Vue.prototype.$serviceUrl + '/auth/user/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 区域信息
  List: function (page, search, order) {
    const data = {
      page, search, order
    }
    return request({
      url: baseUrl + '/regionInfo/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
    // 区域信息
    codeList: function ( search, order) {
      const data = {
        search, order
      }
      return request({
        url: baseUrl + '/regionInfo/list',
        method: 'post',
        data: qs.stringify(data)
      })
    },
  //提取信息
  Get: function (id) {
    const data = {
      id
    };
    return request({
      url: baseUrl + "/regionInfo/get",
      method: "post",
      data: qs.stringify(data)
    });
  },
  GetSchool: function (id) {
    const data = {
      id
    };
    return request({
      url: baseUrl + "/schoolAreaInfo/get",
      method: "post",
      data: qs.stringify(data)
    });
  },
  // 删除校区
  DelSchool: function (ids) {
    const data = {
      ids
    }
    return request({
      url: baseUrl + "/schoolAreaInfo/delete",
      method: "post",
      data: qs.stringify(data)
    });
  },
  // 删除
  Del: function (ids) {
    const data = {
      ids
    }
    return request({
      url: baseUrl + "/regionInfo/delete",
      method: "post",
      data: qs.stringify(data)
    });
  },
  // 保存巡检人员或管理人员
  saveRegionUser: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/regionInfo/saveRegionUser", data, config)
  },
  // 新增校区
  saveSchool: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/schoolAreaInfo/save", data, config)
  },
  save: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/regionInfo/save", data, config)
  }
}